package com.example.cadmin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.cadmin.entity.MyRole;
import com.example.cadmin.entityVo.MenuALLVo;
import com.example.cadmin.entityVo.RoleDto;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author  zzsoft 
 * @since 2023-01-07
 */
public interface MyRoleMapper extends BaseMapper<MyRole> {
    /*
           获取所有的菜单,绘制菜单树
         */
    @Select("select m.menu_id as id,m.parent_id,m.menu_name as title from my_menu as m")
    List<MenuALLVo> buildAll();
    /*
    新建角色
     */
//    @Insert("insert into my_role(role_name, description, create_time, update_time) values (#{roleName}, #{description}, now(), now())")
    int save(RoleDto data);

    /*
    获取角色信息返回map类型
     */
    Map<String,Object> getRole(int roleId);

    /**
     * 通过id查询角色
     * @param roleId
     * @return
     */
    @Select("select r.role_id,r.role_name,r.description,r.create_time,r.update_time from my_role r where r.role_id = #{roleId}")
    MyRole getRoleById(Integer roleId);
}
